package cn.xm.basic.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {

    private Boolean success;
    private String msg;
    private Object resultObj;

    public static AjaxResult me(){
        return new AjaxResult();
    }

    public AjaxResult success(Object resultObj){
        return AjaxResult.me().setSuccess(true).setMsg("请求成功！").setObj(resultObj);
    }

    public AjaxResult fail(Object resultObj){
        return AjaxResult.me().setSuccess(false).setMsg("请求失败！").setObj(resultObj);
    }
    public AjaxResult success(){
        return AjaxResult.me().setSuccess(true).setMsg("请求成功！");
    }

    public AjaxResult fail(String msg){
        return AjaxResult.me().setSuccess(false).setMsg(msg);
    }

    public AjaxResult fail(){
        return AjaxResult.me().setSuccess(false).setMsg("请求失败！");
    }


    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public AjaxResult setObj(Object resultObj) {
        this.resultObj = resultObj;
        return this;
    }
}
